package com.soft.controller;

import com.soft.service.JobChangeService;
import com.soft.utils.Result;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author ruoxi
 * @create 2021-12-28 16:19
 */
@WebServlet("/checkJobChange")
public class CheckJobChangeServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int eno = Integer.parseInt(req.getParameter("eno"));
        String afterjob = req.getParameter("afterjob");
        int state = Integer.parseInt(req.getParameter("state"));

        JobChangeService jobChangeService = new JobChangeService();
        Result result;
        if (state == 0){
            result = jobChangeService.jobChangePass(eno, afterjob);
        }else {
            result = jobChangeService.jobChangeFail(eno);
        }
        req.setAttribute("jobChangeMsg", result);
        req.getRequestDispatcher("showAllJobChangeByPage").forward(req,resp);
    }
}
